package Classes.GameDatas
{
	import Classes.GameUtils.GU_Sound;
	import Classes.GameUtils.GU_dealPower;
	import Classes.GameViews.ViewIcons.ViewIcon;
	import Classes.Managers.M_Communication;

	public class GD_Mission_Collection extends GD_Mission 
	{
		public function GD_Mission_Collection(missionType:Number)
		{
		   super(missionType);
		}
		
		private var _collectMissionType:Number;
		private var _collectTaskStep:int;
		
		public static function creatAllCollectionMissions():Array
		{
			if(null==GD_Mission.missionCollectArr || GD_Mission.missionCollectArr.length<1)
			{
				GD_Mission.missionsConfigObj;
			}
			var creatAry:Array=GD_Mission.missionCollectArr;
			
			var tmpArr:Array=new Array();
			for(var i:int=0;i<creatAry.length;i++)
			{
				var collectMission:GD_Mission_Collection=new GD_Mission_Collection(creatAry[i].zt_task_id);
				collectMission.collectMissionType=creatAry[i].zt_task_type;
				collectMission.collectTaskStep=creatAry[i].zt_task_step;
				tmpArr.push(collectMission);
			}
			return tmpArr;
		}
		
		override public function get conditionCountsAry():Array
		{
			var fatherArr:Array=super.conditionCountsAry;
			var arrLenght:int=fatherArr.length;
			for(var j:int=0;j<arrLenght;j++)
			{
				switch (fatherArr[j].countSecondType)
				{
					case 102:
						var needItemId:Number=fatherArr[j].needItemId;
						var gd_item:GD_Item=linkItem(needItemId);
						fatherArr[j].needItemNum=gd_item.itemNumber;
						fatherArr[j].needItemName=gd_item.itemName;
						fatherArr[j].needItemDes=gd_item.description;
						fatherArr[j].needItemIcon=gd_item.icon;
						(fatherArr[j].needItemIcon as ViewIcon).setNumSpVisiable(false);
						//				(fatherArr[j].needItemIcon as ViewIcon).setNumSpVisiable();
						fatherArr[j].IDg_shop=GD_Shop.instance.getShopInfoByItemInfo(needItemId);
						break;
//					case 22000:
//						break;
				}
				
			}
			fatherArr.sortOn("countType",Array.NUMERIC);
			return fatherArr;
		}
		
		/**
		 * 处理兑换 
		 */		
		override public function finishHandler(isUpBuild:Boolean=false):void
		{
			if(isUpBuild)
			{
				GU_Sound.instance.playCommSound("Button_Building_Upgrade");
				M_Communication.instance.send(12307,{taskId:this.missionType});
				//移除 新手指导时候  武器库的箭头
				if(GU_dealPower.instance.isHavePower(10000211) && null!=GD_Player.instance.missions[11000005])
				{
					GU_dealPower.instance.removeWQKArrow();
				}
			}else{
				M_Communication.instance.send(12304,{missionID:this.missionType});
//				GU_dealSharePreWin.instance.haldSharePreFun(12304);	
				if(missionType==22200001)//这里是11000004里面的合成任务
				{
					GU_dealPower.instance.removeSDArrow();
				}
			}
			
		}
		
		
		private function exchangeResult():void
		{
			
		}
		
		public static function linkItem(itemId:Number):GD_Item
		{
			var gd_item:GD_Item=GD_Player.instance.items[itemId];
			if(null==gd_item)
			{
				var tmpObj:Object={itemType:itemId,itemNum:0};
				gd_item=GD_Item.creat(tmpObj);
			}
			return gd_item;
		}

		/**
		 * 收藏任务类型 
		 */
		public function get collectMissionType():Number
		{
			return _collectMissionType;
		}

		/**
		 * @private
		 */
		public function set collectMissionType(value:Number):void
		{
			_collectMissionType = value;
		}

		/**
		 * 任务步骤 
		 */
		public function get collectTaskStep():int
		{
			return _collectTaskStep;
		}

		/**
		 * @private
		 */
		public function set collectTaskStep(value:int):void
		{
			_collectTaskStep = value;
		}
		
		
		
	
	}
}